#include <iostream>
#include <iomanip>

void demonstrate_digit_separators() {
    // C++14引入数字分隔符(')，提高长数字的可读性
    
    // 整数使用分隔符
    int million = 1'000'000;
    long long very_large = 12'345'678'901'234'567LL;
    
    std::cout << "  使用数字分隔符的整数:\n";
    std::cout << "  1'000'000 = " << million << '\n';
    std::cout << "  12'345'678'901'234'567LL = " << very_large << '\n';
    
    // 浮点数使用分隔符
    double pi = 3.141'592'653'589'793;
    double electron_mass = 9.109'383'7015e-31;
    
    std::cout << "\n  使用数字分隔符的浮点数:\n";
    std::cout << "  π = " << std::setprecision(15) << pi << '\n';
    std::cout << "  电子质量 = " << std::scientific << electron_mass << " kg\n";
    
    // 不同进制的数字也可以使用分隔符
    std::cout << "\n  在不同进制中使用分隔符:\n";
    int binary = 0b1010'0001'1000'0101;
    int octal = 0'123'456'777;
    int hex = 0xAB'CD'EF'12;
    
    std::cout << "  二进制: 0b1010'0001'1000'0101 = " << binary << '\n';
    std::cout << "  八进制: 0'123'456'777 = " << octal << '\n';
    std::cout << "  十六进制: 0xAB'CD'EF'12 = " << std::hex << std::uppercase << hex << '\n';
    
    // 分隔符可以任意放置
    std::cout << "\n  分隔符的灵活放置:\n";
    long long credit_card = 1234'5678'9012'3456LL;  // 按照4位分组（使用long long避免溢出）
    long phone = 1'555'123'4567;            // 按照电话号码格式分组
    int zip_code = 12345'6789;              // 按照邮政编码格式分组
    
    std::cout << std::dec;
    std::cout << "  信用卡号: " << credit_card << '\n';
    std::cout << "  电话号码: " << phone << '\n';
    std::cout << "  邮政编码: " << zip_code << '\n';
} 